package com.hq.mes.bussiness;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import javax.validation.constraints.NotBlank;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;

//@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
@MappedSuperclass
@DynamicUpdate
@DynamicInsert

public class BussinessBaseEntity extends BaseEntity{
	
	@Column(columnDefinition = "bigint  COMMENT 'id'" ,insertable=false ,updatable=false)
    @Id  
    @NotBlank(groups = Update.class)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
  
    private Long id;
	
	@Version
    private int version;
    
    @NotBlank
    @Column( unique=true,columnDefinition = "varchar(36) not null COMMENT '编码'")
    private String code;
    @NotBlank
    @Column(columnDefinition = "varchar(36) not null COMMENT '名称'")
    private String name;
    
    
    @Column(columnDefinition = "varchar(255) COMMENT '备注'")
    private String remark;
    
    @Column( columnDefinition = "varchar(25) default 'false' COMMENT '是否已删除'",insertable = false)
    /* 0:表示启用,1:表示已删除 */
    private String is_del;
    
    public void copy(BussinessBaseEntity source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

}